//点击a标签，获取属性load，访问该url，到内容div中添加
$(function(){
	$("li a").click(function(){
		var url = $(this).attr("load");
		var obj = this;
		$("#pageContent").load(url,function(){
			$("li a").parent().removeClass("active");
			$(obj).parent().addClass("active");
		});
	});
});

//图片选择框点击时触发文件上传框的点击
$("body").on("click",".uploadImg",function(){
	$(this).siblings().eq(0).trigger("click");
});
//选择好图片后，实时更新图片内容，并将字符串赋值给隐藏的name
function uploadImg(obj){
	var formData = new FormData();
	var thisStr = obj;
	var thisObj = document.getElementById(thisStr);
	 formData.append("file", thisObj.files[0]);  
	$.ajax({
		 url: "durose_upload_picture",
        type: "POST",
        data: formData,
		contentType: false,
       processData: false,
       success: function (data) {
    	   //图片框图片更新
    	   $(thisObj).siblings().eq(0).attr("src","static/img/"+data);
    	   //隐藏name框赋值
    	   $(thisObj).siblings().eq(1).val(data);
       }
	});
}
//对日期进行转化
function initDate(date){
	var d = new Date(parseInt(date));
 	var year = d.getFullYear();
 	var month = d.getMonth()+1;
 	var day = d.getDate();
 	return year+"-"+month+"-"+day;
}

//对时间进行转化
function initDateBySecond(date){
	var d = new Date(parseInt(date));
 	var year = d.getFullYear();
 	var month = d.getMonth()+1;
 	var day = d.getDate();
 	var hour = d.getHours();
 	var minute = d.getMinutes();
 	var second = d.getSeconds();
 	return year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second;
}